package offer;

/**
 * @author cyt
 * @create 2020-05-19 18:12
 */
public class T11 {

    static int ans = 0;

    /**
     * 二进制中  1  的个数
     *
     * @param args
     */
    public static void main(String[] args) {

//        NumberOf1(5);
//        System.out.println(ans);

        String string = Integer.toBinaryString(-3);
        char[] charArray = string.toCharArray();
        for (char c : charArray) {
            if (c == '1') {
                ans++;
            }
        }
        System.out.println();
    }

    static void NumberOf1(int num) {
        while (num > 0) {
            if (num % 2 == 1) {
                ans++;
            }
            num = num / 2;
        }
    }
}
